/*
Copyright (C) 1996-1997 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

#include "quakedef.h"
#include "menu.shared.h"


class qmenu_help : public qmenu_t
{
public:
	qmenu_help (void)
	{
		this->Register (m_help);

		this->HelpCursor = 0;
		this->MaxHelpPages = 6;
	}

	void EnterFunc (void)
	{
		this->EnterMenu ();

		// hide the ordering screen in the registered version
		if (registered->value)
			this->HelpCursor = 1;
		else this->HelpCursor = 0;
	}

	BOOL KeyFunc (int key)
	{
		switch (key)
		{
		case K_UPARROW:
		case K_LEFTARROW:
			this->NavigateHelp (-1, this->MaxHelpPages - 1);
			return TRUE;

		case K_DOWNARROW:
		case K_RIGHTARROW:
			this->NavigateHelp (1, 1);
			return TRUE;
		}

		return FALSE;
	}

protected:
	void NavigateHelp (int dir, int overridepage)
	{
		this->HelpCursor += dir;

		if (this->HelpCursor < 0) this->HelpCursor = this->MaxHelpPages - 1;
		if (this->HelpCursor >= this->MaxHelpPages) this->HelpCursor = 0;

		// hide the ordering screen in the registered version
		if (registered->value && this->HelpCursor == 0) this->HelpCursor = overridepage;
	}

	int HelpCursor;
	int MaxHelpPages;

	void CustomDraw (void)
	{
		M_DrawPic (0, 0, Draw_CachePic (va ("gfx/help%i.lmp", this->HelpCursor)));
	}
} menu_help;

